package com.example.permission.controller;

import com.example.permission.model.req.SystemRoleDTO;
import com.example.permission.model.resp.SystemRoleVO;
import com.example.permission.service.SystemRoleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author qwer3
 * @version 1.0.0
 * @create 2025/11/16 11:25
 */
@RestController
@RequestMapping("/api/sys/role")
@RequiredArgsConstructor
public class RoleController {
    private final SystemRoleService systemRoleService;

    @GetMapping("/list")
    public List<SystemRoleVO> getSystemRole() {
        return systemRoleService.getSystemRole();
    }

    @GetMapping("/detail/{roleId}")
    public SystemRoleDTO getSystemRoleDetail(@PathVariable("roleId") String roleId) {
        return systemRoleService.getSystemRoleDetail(roleId);
    }

    @PostMapping("/create")
    public void createRole(@RequestBody SystemRoleDTO systemRoleDTO) {
        systemRoleService.createOrModifyRole(systemRoleDTO);
    }

    @PutMapping("/update")
    public void updateRole(@RequestBody SystemRoleDTO systemRoleDTO) {
        systemRoleService.createOrModifyRole(systemRoleDTO);
    }

    @DeleteMapping("/delete/{roleId}")
    public void deleteRole(@PathVariable("roleId") String roleId) {
        systemRoleService.deleteRole(roleId);
    }
}
